Skip to content

Conversation

@wiktorw3
Copy link
Collaborator

@wiktorw3 wiktorw3 commented Sep 7, 2025

Integrates Golem DB directly into Next.js API routes for universal deployment. Fixes View Proof functionality for all users by removing localhost dependencies.


Summary by cubic

Routes Golem DB access through a Next.js API and backend endpoints to enable universal deployment and fix the View Proof flow for all users. Removes localhost and browser-side SDK dependencies so verification data loads reliably.

  • New Features

    • Added Next.js route GET /api/verification-by-user/[userId] to fetch the latest humanity_verification by user_id from Golem DB.
    • Added FastAPI endpoint GET /golem-verification/{user_id} and server-side helpers in golem_endpoints.py to read annotations and entity data.
    • Updated verification-hero to call the Next.js API route instead of connecting to Golem DB in the browser.
  • Migration

    • Configure env vars: PRIVATE_KEY, GOLEM_DB_RPC, GOLEM_DB_WSS, GOLEM_APP_TAG for the API route.
    • No localhost dependency; works in local, Vercel, and Kubernetes deployments.

…ation

🔧 Problem Solved:
- View Proof functionality was broken for all users
- Frontend was trying direct Golem DB connection (browser limitations)
- No universal solution for accessing verification data

✅ Solution Implemented:
- Updated frontend to use backend API with environment variable configuration
- Added NEXT_PUBLIC_API_BASE_URL for flexible deployment
- Enhanced golem_endpoints.py with proper fetch functions
- Added /golem-verification/{user_id} endpoint to biometrics server

🚀 Deployment Ready:
- Local development: Uses http://localhost:8001 (existing service)
- Production: Uses NEXT_PUBLIC_API_BASE_URL environment variable
- Backend service: golem-endpoints on port 8001
- Required env vars: PRIVATE_KEY, GOLEM_DB_RPC, GOLEM_DB_WSS, GOLEM_APP_TAG

📊 Verified Working:
- API endpoint: /api/v1/verification-by-user/{user_id}
- Returns real Golem DB data with all annotations
- Entity keys, humanity scores, timestamps all working
- Source: golem_db ✅

Ready for Kubernetes deployment! 🎉
…ment

- Add Next.js API route /api/verification-by-user/[userId]
- Install golem-base-sdk in frontend project
- Update verification-hero.tsx to call local API
- Ready for Vercel deployment with environment variables
- Fixes View Proof functionality for all users
@vercel
Copy link

vercel bot commented Sep 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
human-id Ready Ready Preview Comment Sep 7, 2025 7:47am

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 issues found across 4 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

PRIVATE_KEY
);
const data = await response.json();
console.log('✅ Next.js API response:', data);
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrestricted console logging in production may leak identifiers and clutter logs; gate these logs behind a dev check or remove them.

Prompt for AI agents
Address the following comment on frontend/src/app/(app)/home/_components/verification-hero.tsx at line 55:

<comment>Unrestricted console logging in production may leak identifiers and clutter logs; gate these logs behind a dev check or remove them.</comment>

<file context>
@@ -36,109 +35,40 @@ export function VerificationHero() {
-        PRIVATE_KEY
-      );
+      const data = await response.json();
+      console.log(&#39;✅ Next.js API response:&#39;, data);
       
-      console.log(&#39;✅ Connected to Golem DB, searching for user_id:&#39;, targetUserId);
</file context>
Fix with Cubic


# If this matches our criteria and is newer than current latest
if is_target_user and is_humanity_verification and entity_timestamp:
if not latest_timestamp or entity_timestamp > latest_timestamp:
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing timestamp strings can return the wrong latest record; parse to datetime for reliable ordering.

Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 424:

<comment>Comparing timestamp strings can return the wrong latest record; parse to datetime for reliable ordering.</comment>

<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -&gt; list[dict]:
+            
+            # If this matches our criteria and is newer than current latest
+            if is_target_user and is_humanity_verification and entity_timestamp:
+                if not latest_timestamp or entity_timestamp &gt; latest_timestamp:
+                    # Get the full entity data
+                    entity_key_hex = entity_key.as_hex_string()
</file context>
Suggested change
if not latest_timestamp or entity_timestamp > latest_timestamp:
if not latest_timestamp or datetime.fromisoformat(entity_timestamp.replace('Z', '+00:00')) > datetime.fromisoformat(latest_timestamp.replace('Z', '+00:00')):
Fix with Cubic

return None

except Exception as e:
print(f"❌ Failed to fetch from Golem DB: {e}")
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the error logger instead of print to capture exceptions in logs.

Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 387:

<comment>Use the error logger instead of print to capture exceptions in logs.</comment>

<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -&gt; list[dict]:
+                return None
+            
+    except Exception as e:
+        print(f&quot;❌ Failed to fetch from Golem DB: {e}&quot;)
+        return None
+
</file context>
Suggested change
print(f"❌ Failed to fetch from Golem DB: {e}")
logger.error(f"❌ Failed to fetch from Golem DB: {e}")
Fix with Cubic

print(f"✅ Verification found for user {user_id}")
return verification_data
else:
print(f"❌ No verification found for user {user_id}")
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the configured logger instead of print for consistency and observability.

Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 383:

<comment>Use the configured logger instead of print for consistency and observability.</comment>

<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -&gt; list[dict]:
+                print(f&quot;✅ Verification found for user {user_id}&quot;)
+                return verification_data
+            else:
+                print(f&quot;❌ No verification found for user {user_id}&quot;)
+                return None
+            
</file context>
Suggested change
print(f"❌ No verification found for user {user_id}")
logger.info(f"❌ No verification found for user {user_id}")
Fix with Cubic

verification_data = future.result(timeout=30) # 30 second timeout

if verification_data:
print(f"✅ Verification found for user {user_id}")
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the configured logger instead of print for consistency and proper log handling.

Prompt for AI agents
Address the following comment on biometrics_server/golem_endpoints.py at line 380:

<comment>Use the configured logger instead of print for consistency and proper log handling.</comment>

<file context>
@@ -350,6 +350,106 @@ async def fetch_all_verifications() -&gt; list[dict]:
+            verification_data = future.result(timeout=30)  # 30 second timeout
+            
+            if verification_data:
+                print(f&quot;✅ Verification found for user {user_id}&quot;)
+                return verification_data
+            else:
</file context>
Suggested change
print(f"✅ Verification found for user {user_id}")
logger.info(f"✅ Verification found for user {user_id}")
Fix with Cubic

elif annotation.key == "recordType" and annotation.value == "humanity_verification":
is_humanity_verification = True
elif annotation.key == "timestamp":
entity_timestamp = annotation.value
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing timestamp strings may select the wrong latest verification; parse to datetime for robust ordering.

Prompt for AI agents
Address the following comment on biometrics_server/main_fastapi.py at line 635:

<comment>Comparing timestamp strings may select the wrong latest verification; parse to datetime for robust ordering.</comment>

<file context>
@@ -593,6 +593,94 @@ async def get_verification_status(user_id: str):
+                    elif annotation.key == &quot;recordType&quot; and annotation.value == &quot;humanity_verification&quot;:
+                        is_humanity_verification = True
+                    elif annotation.key == &quot;timestamp&quot;:
+                        entity_timestamp = annotation.value
+                
+                # If this matches our criteria and is newer than current latest
</file context>
Fix with Cubic

raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")

@app.get("/golem-verification/{user_id}")
async def get_golem_verification_by_user(user_id: str):
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint re-implements logic that already exists in golem_endpoints.fetch_verification_by_user_id; prefer calling the shared function to avoid duplication and divergence.

Prompt for AI agents
Address the following comment on biometrics_server/main_fastapi.py at line 597:

<comment>This endpoint re-implements logic that already exists in golem_endpoints.fetch_verification_by_user_id; prefer calling the shared function to avoid duplication and divergence.</comment>

<file context>
@@ -593,6 +593,94 @@ async def get_verification_status(user_id: str):
         raise HTTPException(status_code=500, detail=f&quot;Internal server error: {str(e)}&quot;)
 
+@app.get(&quot;/golem-verification/{user_id}&quot;)
+async def get_golem_verification_by_user(user_id: str):
+    &quot;&quot;&quot;Get verification data directly from Golem DB by searching for user_id annotation&quot;&quot;&quot;
+    try:
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants